package org.deadline.service.config;

import java.util.List;
import org.deadline.model.config.StateProvince;
import org.deadline.repository.config.StateProvinceRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class StateProvinceServiceImpl implements StateProvinceService {

	@Autowired
    StateProvinceRepository stateProvinceRepository;

	public long countAllStateProvinces() {
        return stateProvinceRepository.count();
    }

	public void deleteStateProvince(StateProvince stateProvince) {
        stateProvinceRepository.delete(stateProvince);
    }

	public StateProvince findStateProvince(Long id) {
        return stateProvinceRepository.findOne(id);
    }

	public List<StateProvince> findAllStateProvinces() {
        return stateProvinceRepository.findAll();
    }

	public List<StateProvince> findStateProvinceEntries(int firstResult, int maxResults) {
        return stateProvinceRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveStateProvince(StateProvince stateProvince) {
        stateProvinceRepository.save(stateProvince);
    }

	public StateProvince updateStateProvince(StateProvince stateProvince) {
        return stateProvinceRepository.save(stateProvince);
    }
}
